<template>
  <div id="cart">
    <!-- 头部 -->
    <NavBar class="nav-bar">
      <div slot="center">购物车({{ length }})</div>
    </NavBar>
    <!-- 主体区域 -->
    <Scroll class="cart-scroll" ref="scroll">
      <CartList/>
    </Scroll>
    <!-- 底部汇总 -->
    <CartBottomBar/>
  </div>
</template>

<script>
import NavBar from 'components/common/navbar/NavBar'
import CartList from './childComps/CartList'
import CartBottomBar from './childComps/CartBottomBar'
import Scroll from 'components/common/scroll/Scroll'
import { mapGetters } from 'vuex'

export default {
  name:'Shop',
  components: {
    NavBar,
    CartList,
    Scroll,
    CartBottomBar
  },
  computed: {
    ...mapGetters({
      length:'cartLength',
    })
  },
  activated() {
    this.$refs.scroll.refresh();
  }
}
</script>

<style scoped>
  #cart {
    height: 100vh;
  }
  .nav-bar {
    background-color: #ff5777;
    color: white;
  }
  .cart-scroll {
    height: calc(100% - 49px - 44px - 40px);
    overflow: hidden;
  }
</style>